<template>
  <div class="liumian">
    <div class="content_title">
      <span class="content_text">梳棉</span>
      <img
        class="content_img"
        src="@/assets/img/chart/liumian.png"
        alt=""
        srcset=""
      />
    </div>
    <div class="liumian_body">
      <div class="liumianRol">
        <div
          v-for="(item, index) in liumianData.liumianRow1Data"
          :key="index + 'g'"
          class="liumian_item"
        >
          <div v-if="index == 7">
            <div class="dongli" @click="clickHandleDl('shumian1_' + index)">
              <img src="@/assets/img/dongliguis.png" alt="" srcset="" />
            </div>
          </div>
          <div @click="clickHandle('liumian', item)">
            <liumian :data="item"></liumian>
          </div>
        </div>
      </div>
      <div class="liumianRol">
        <div
          v-for="(item, index) in liumianData.liumianRow2Data"
          :key="index + 'h'"
          class="liumian_item"
        >
          <div v-if="index == 7">
            <div class="dongli" @click="clickHandleDl('shumian2_' + index)">
              <img src="@/assets/img/dongliguis.png" alt="" srcset="" />
            </div>
          </div>
          <div @click="clickHandle('liumian', item)">
            <liumian :data="item"></liumian>
          </div>
        </div>
      </div>
      <div class="liumianRol">
        <div
          v-for="(item, index) in liumianData.liumianRow3Data"
          :key="index + 'j'"
          class="liumian_item"
        >
          <div v-if="index == 7">
            <div class="dongli" @click="clickHandleDl('shumian3_' + index)">
              <img src="@/assets/img/dongliguis.png" alt="" srcset="" />
            </div>
          </div>
          <div @click="clickHandle('liumian', item)">
            <liumian :data="item"></liumian>
          </div>
        </div>
      </div>
      <div class="liumianRol">
        <div
          v-for="(item, index) in liumianData.liumianRow4Data"
          :key="index + 'k'"
          class="liumian_item"
        >
          <div v-if="index == 7">
            <div class="dongli" @click="clickHandleDl('shumian4_' + index)">
              <img src="@/assets/img/dongliguis.png" alt="" srcset="" />
            </div>
          </div>
          <div @click="clickHandle('liumian', item)">
            <liumian :data="item"></liumian>
          </div>
        </div>
      </div>
    </div>
    <!-- 梳棉弹窗控件 -->
    <liumianDialog ref="liumianDialog"></liumianDialog>
    <!-- 动力柜弹窗控件 -->
    <dongliDialog ref="dongliDialog"></dongliDialog>
  </div>
</template>

<script>
import dongliDialog from '../qcs/dialog/dialog_dongli/index';
import liumianDialog from '../qcs/dialog/dialog_liumian/index';
import liumian from '../qcs/liumian';
import COMMON from '@/utils/common';
import dongLiMenu from '../data/dongli.json';
import dongliItem from '../data/dongliItem.json';
export default {
  name: 'ShuMian',
  props: {
    msg: String
  },
  components: {
    dongliDialog,
    liumian,
    liumianDialog
  },
  data() {
    return {
      liumianData: {
        // 1-8
        liumianRow1Data: [],
        // 9-16
        liumianRow2Data: [],
        // 17-24
        liumianRow3Data: [],
        // 25-32
        liumianRow4Data: [],
        dongLiMenu: {},
        dongLiItem: {}
      }
    };
  },
  created() {
    this.dongLiMenu = dongLiMenu;
    this.dongLiItem = dongliItem;
  },
  methods: {
    closeHandle() {
      this.$parent.$parent.$parent.closeParentHandle();
    },
    clickHandle(flag, item) {
      this.$parent.$parent.$parent.getInfoByDevSn('SHUMIANJI', item.devSn);
      this.$refs.liumianDialog.showDialog(item);
    },
    clickHandleDl(item) {
      var getInfoQuary = this.dongLiMenu[item];
      var dialogData = this.dongLiItem[item];
      this.$parent.$parent.$parent.getInfoByDevSn('DONGLI', getInfoQuary);
      this.$refs.dongliDialog.showDialog(dialogData);
    }
  },
  computed: {
    shuMianJiGroupState() {
      return this.$store.state.workshop.shuMianJiGroupState;
    }
  },
  watch: {
    shuMianJiGroupState: {
      immediate: true,
      handler(val) {
        this.liumianData.liumianRow1Data = COMMON.devSnFilter(val.data1, 1, 8);
        this.liumianData.liumianRow2Data = COMMON.devSnFilter(val.data1, 9, 16);
        this.liumianData.liumianRow3Data = COMMON.devSnFilter(
          val.data2,
          17,
          24
        );
        this.liumianData.liumianRow4Data = COMMON.devSnFilter(
          val.data2,
          25,
          32
        );
      }
    }
  }
};
</script>

<style scoped></style>
